/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <flgrCoreData.h>
#include <flgrCoreDataIO.h>
#include <flgrCoreDispatch.h>
#include <flgrCoreMalloc.h>
#include "flgrCoreCompare.h"
#include "flgrCoreReplace.h"
#include "flgrCoreReplaceFast.h"


/*!
 * \addtogroup group_fulguro_core_compare
 * @{
 */


//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// 1D REPLACE FUNCTIONS
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_I
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(dtype)	\
  int j;						\
  int length = datout->length * datout->spp;		\
  dtype *pout,*ptest1,*ptest2;				\
  dtype *ptrue, *pfalse;				\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype *) dattest2->array;			\
  ptrue = (dtype *) dattrue->array;			\
  pfalse = (dtype *) datfalse->array;			\
							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return





///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_C
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(dtype)	\
  int j;						\
  int spp = datout->spp;				\
  int length = datout->length * datout->spp;		\
  dtype *pout,*ptest1,*ptest2;				\
  dtype *ptrue;						\
  dtype *pfalse;					\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype *) dattest2->array;			\
  ptrue = (dtype *) dattrue->array;			\
  pfalse = (dtype*) vec_false->array;			\
  							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      vfalse = flgr_get_array_##dtype(pfalse,j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vfalse = flgr_get_array_##dtype(pfalse,j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      vfalse = flgr_get_array_##dtype(pfalse,j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vfalse = flgr_get_array_##dtype(pfalse,j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      vfalse = flgr_get_array_##dtype(pfalse,j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      vfalse = flgr_get_array_##dtype(pfalse,j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return




///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_I
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(dtype)	\
  int j;						\
  int spp = datout->spp;				\
  int length = datout->length * datout->spp;		\
  dtype *pout,*ptest1,*ptest2;				\
  dtype *pfalse, *ptrue;				\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype *) dattest2->array;			\
  pfalse = (dtype *) datfalse->array;			\
  ptrue  = (dtype*) vec_true->array;			\
							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return






///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_I
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(dtype)	\
  int j;						\
  int spp = datout->spp;				\
  int length = datout->length * datout->spp;		\
  dtype *pout,*ptest1,*ptest2;				\
  dtype *ptrue,*pfalse;					\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype *) dattest2->array;			\
  ptrue  = (dtype*) vec_true->array;			\
  pfalse = (dtype*) vec_false->array;			\
							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtest2 = flgr1d_get_data_array_##dtype(ptest2,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return







///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_I
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(dtype)	\
  int j;						\
  int spp = datout->spp;				\
  int length = datout->length * datout->spp;		\
  dtype *pout,*ptest1,*ptest2;				\
  dtype *ptrue, *pfalse;				\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype*) vec_test2->array;			\
  ptrue = (dtype *) dattrue->array;			\
  pfalse = (dtype *) datfalse->array;			\
							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return





///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_C
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(dtype)	\
  int j;						\
  int spp = datout->spp;				\
  int length = datout->length * datout->spp;		\
  dtype *pout,*ptest1,*ptest2;				\
  dtype *ptrue,*pfalse;					\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype*) vec_test2->array;			\
  ptrue = (dtype *) dattrue->array;			\
  pfalse = (dtype*) vec_false->array;			\
							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vfalse = flgr_get_array_##dtype(pfalse, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vtrue = flgr1d_get_data_array_##dtype(ptrue,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return




///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_I
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(dtype)	\
  int j;						\
  int spp = datout->spp;				\
  int length = datout->length * datout->spp;		\
  dtype *pout,*ptest1,*ptest2;				\
  dtype *ptrue,*pfalse;					\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype*) vec_test2->array;			\
  ptrue = (dtype*) vec_true->array;			\
  pfalse = (dtype *) datfalse->array;			\
							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      vtest2 = flgr_get_array_##dtype(ptest2, j%spp);	\
      vtrue = flgr_get_array_##dtype(ptrue, j%spp);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vfalse = flgr1d_get_data_array_##dtype(pfalse,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return






///////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_I
///////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(dtype)	\
  int j,k;						\
  int spp = datout->spp;				\
  int length = datout->length * datout->spp;		\
  dtype *pout, *ptest1, *ptest2;			\
  dtype *ptrue, *pfalse;				\
  dtype vout,vtest1,vtest2,vtrue,vfalse;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  pout = (dtype *) datout->array;			\
  ptest1 = (dtype *) dattest1->array;			\
  ptest2 = (dtype*) vec_test2->array;			\
  ptrue = (dtype*) vec_true->array;			\
  pfalse = (dtype*) vec_false->array;			\
							\
  switch(test) {					\
  case FLGR_TEST_INF:					\
    for(j=0 ; j<length ; j++) {				\
      k = j%spp;					\
      vtest2 = flgr_get_array_##dtype(ptest2, k);	\
      vtrue = flgr_get_array_##dtype(ptrue, k);		\
      vfalse = flgr_get_array_##dtype(pfalse, k);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vout = (vtest1<vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_INFEQ:					\
    for(j=0 ; j<length ; j++) {				\
      k = j%spp;					\
      vtest2 = flgr_get_array_##dtype(ptest2, k);	\
      vtrue = flgr_get_array_##dtype(ptrue, k);		\
      vfalse = flgr_get_array_##dtype(pfalse, k);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vout = (vtest1<=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_EQ:					\
    for(j=0 ; j<length ; j++) {				\
      k = j%spp;					\
      vtest2 = flgr_get_array_##dtype(ptest2, k);	\
      vtrue = flgr_get_array_##dtype(ptrue, k);		\
      vfalse = flgr_get_array_##dtype(pfalse, k);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vout = (vtest1==vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUPEQ:					\
    for(j=0 ; j<length ; j++) {				\
      k = j%spp;					\
      vtest2 = flgr_get_array_##dtype(ptest2, k);	\
      vtrue = flgr_get_array_##dtype(ptrue, k);		\
      vfalse = flgr_get_array_##dtype(pfalse, k);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vout = (vtest1>=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  case FLGR_TEST_SUP:					\
    for(j=0 ; j<length ; j++) {				\
      k = j%spp;					\
      vtest2 = flgr_get_array_##dtype(ptest2, k);	\
      vtrue = flgr_get_array_##dtype(ptrue, k);		\
      vfalse = flgr_get_array_##dtype(pfalse, k);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vout = (vtest1>vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
    break;						\
							\
  default:						\
    for(j=0 ; j<length ; j++) {				\
      k = j%spp;					\
      vtest2 = flgr_get_array_##dtype(ptest2, k);	\
      vtrue = flgr_get_array_##dtype(ptrue, k);		\
      vfalse = flgr_get_array_##dtype(pfalse, k);	\
      vtest1 = flgr1d_get_data_array_##dtype(ptest1,j);	\
      vout = (vtest1!=vtest2) ? vtrue : vfalse;		\
      flgr1d_set_data_array_##dtype(pout,j,vout);	\
    }							\
  }							\
							\
  return






void flgr1d_replace_I_with_I_I_I_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
				       FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgBIT);
}

void flgr1d_replace_I_with_I_I_I_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_I_I_I_fast_fgUINT8(datout,dattest1,dattest2,dattrue,datfalse);

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_I_I_I_fast_fgUINT8(datout,dattest1,dattest2,dattrue,datfalse);

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_I_I_I_fast_fgUINT8(datout,dattest1,dattest2,dattrue,datfalse);

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_I_I_I_fast_fgUINT8(datout,dattest1,dattest2,dattrue,datfalse);

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgUINT8);
  }
#else
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgUINT8);
#endif

}

void flgr1d_replace_I_with_I_I_I_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgUINT16);
}

void flgr1d_replace_I_with_I_I_I_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgUINT32);
}

void flgr1d_replace_I_with_I_I_I_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgINT8);
}

void flgr1d_replace_I_with_I_I_I_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgINT16);
}

void flgr1d_replace_I_with_I_I_I_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgINT32);
}

void flgr1d_replace_I_with_I_I_I_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgFLOAT32);
}

void flgr1d_replace_I_with_I_I_I_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_I(fgFLOAT64);
}




////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param dattrue
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_I_I_I(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Data1D *dattest2,
				     FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (dattrue==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest2, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattrue, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_I_I_I,datout,dattest1,tst,dattest2,dattrue,datfalse);

  return FLGR_RET_OK;

}




void flgr1d_replace_I_with_I_I_C_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
				       FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgBIT);
}

void flgr1d_replace_I_with_I_I_C_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_I_I_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_I_I_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_I_I_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_I_I_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgUINT8);
  }

#else
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgUINT8);
#endif
}

void flgr1d_replace_I_with_I_I_C_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgUINT16);
}

void flgr1d_replace_I_with_I_I_C_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgUINT32);
}

void flgr1d_replace_I_with_I_I_C_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgINT8);
}

void flgr1d_replace_I_with_I_I_C_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgINT16);
}

void flgr1d_replace_I_with_I_I_C_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgINT32);
}

void flgr1d_replace_I_with_I_I_C_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgFLOAT32);
}

void flgr1d_replace_I_with_I_I_C_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_I_C(fgFLOAT64);
}

////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param dattrue
 *  @param vec_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_I_I_C(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Data1D *dattest2,
				     FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (dattrue==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest2, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_I_I_C,datout,dattest1,tst,dattest2,dattrue,vec_false);


}

////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param dattrue
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_I_I_S(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Data1D *dattest2,
				     FLGR_Data1D *dattrue, char *str_false) {
  int ret;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (dattrue==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr1d_replace_I_with_I_I_C(datout,dattest1,test,dattest2,dattrue,vector_false);

  flgr_vector_destroy(vector_false);

  return ret;

}





void flgr1d_replace_I_with_I_C_I_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
				       FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgBIT);
}

void flgr1d_replace_I_with_I_C_I_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_I_C_I_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     datfalse);

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_I_C_I_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     datfalse);

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_I_C_I_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0)
					     ,datfalse);

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_I_C_I_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     datfalse);

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgUINT8);
  }
#else
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgUINT8);
#endif
}

void flgr1d_replace_I_with_I_C_I_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgUINT16);
}

void flgr1d_replace_I_with_I_C_I_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgUINT32);
}

void flgr1d_replace_I_with_I_C_I_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgINT8);
}

void flgr1d_replace_I_with_I_C_I_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgINT16);
}

void flgr1d_replace_I_with_I_C_I_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgINT32);
}

void flgr1d_replace_I_with_I_C_I_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgFLOAT32);
}

void flgr1d_replace_I_with_I_C_I_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_I(fgFLOAT64);
}


////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param vec_true
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_I_C_I(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Data1D *dattest2,
				     FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest2, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_I_C_I,datout,dattest1,tst,dattest2,vec_true,datfalse);

}
////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param str_true
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_I_S_I(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Data1D *dattest2,
				     char *str_true, FLGR_Data1D *datfalse) {
  int ret;
  FLGR_Vector *vector_true;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (datfalse==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_true = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }


  ret = flgr1d_replace_I_with_I_C_I(datout,dattest1,test,dattest2,vector_true,datfalse);

  flgr_vector_destroy(vector_true);

  return ret;

}




void flgr1d_replace_I_with_I_C_C_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
				       FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgBIT);
}

void flgr1d_replace_I_with_I_C_C_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_I_C_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_I_C_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_I_C_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_I_C_C_fast_fgUINT8(datout,
					     dattest1,
					     dattest2,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgUINT8);
  }
#else
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgUINT8);
#endif
}

void flgr1d_replace_I_with_I_C_C_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgUINT16);
}

void flgr1d_replace_I_with_I_C_C_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					  FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgUINT32);
}

void flgr1d_replace_I_with_I_C_C_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgINT8);
}

void flgr1d_replace_I_with_I_C_C_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgINT16);
}

void flgr1d_replace_I_with_I_C_C_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgINT32);
}

void flgr1d_replace_I_with_I_C_C_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgFLOAT32);
}

void flgr1d_replace_I_with_I_C_C_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Data1D *dattest2,
					   FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_I_C_C(fgFLOAT64);
}


////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param vec_true
 *  @param vec_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_I_C_C(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Data1D *dattest2,
				     FLGR_Vector *vec_true, FLGR_Vector *vec_false) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_I_C_C,datout,dattest1,tst,dattest2,vec_true,vec_false);


}
////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param str_true
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_I_S_S(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Data1D *dattest2,
				     char *str_true, char *str_false) {
  int ret;
  FLGR_Vector *vector_true;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_true = flgr_vector_create(datout->spp,datout->type);
  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr1d_replace_I_with_I_C_C(datout,dattest1,test,dattest2,vector_true,vector_false);

  flgr_vector_destroy(vector_true);
  flgr_vector_destroy(vector_false);

  return ret;

}








void flgr1d_replace_I_with_C_I_I_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
				       FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgBIT);
}

void flgr1d_replace_I_with_C_I_I_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_C_I_I_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     datfalse);

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_C_I_I_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     datfalse);

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_C_I_I_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     datfalse);

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_C_I_I_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     datfalse);

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgUINT8);
  }
#else
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgUINT8);
#endif
}

void flgr1d_replace_I_with_C_I_I_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgUINT16);
}

void flgr1d_replace_I_with_C_I_I_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgUINT32);
}

void flgr1d_replace_I_with_C_I_I_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgINT8);
}

void flgr1d_replace_I_with_C_I_I_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgINT16);
}

void flgr1d_replace_I_with_C_I_I_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgINT32);
}

void flgr1d_replace_I_with_C_I_I_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgFLOAT32);
}

void flgr1d_replace_I_with_C_I_I_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_I(fgFLOAT64);
}




////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : test operand 2
 *  @param dattrue
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_C_I_I(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Vector *vec_test2,
				     FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattrue==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest1, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattrue, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_C_I_I,datout,dattest1,tst,vec_test2,dattrue,datfalse);


}
////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param dattrue
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_S_I_I(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, char *str_test2,
				     FLGR_Data1D *dattrue, FLGR_Data1D *datfalse) {
  int ret;
  FLGR_Vector *vector_test2;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattrue==NULL) || (datfalse==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }


  ret = flgr1d_replace_I_with_C_I_I(datout,dattest1,test,vector_test2,dattrue,datfalse);

  flgr_vector_destroy(vector_test2);

  return ret;

}




void flgr1d_replace_I_with_C_I_C_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
				       FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgBIT);
}

void flgr1d_replace_I_with_C_I_C_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_C_I_C_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_C_I_C_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_C_I_C_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_C_I_C_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0) ,
					     dattrue,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgUINT8);
  }
#else
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgUINT8);
#endif
}

void flgr1d_replace_I_with_C_I_C_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgUINT16);
}

void flgr1d_replace_I_with_C_I_C_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgUINT32);
}

void flgr1d_replace_I_with_C_I_C_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgINT8);
}

void flgr1d_replace_I_with_C_I_C_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgINT16);
}

void flgr1d_replace_I_with_C_I_C_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgINT32);
}

void flgr1d_replace_I_with_C_I_C_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgFLOAT32);
}

void flgr1d_replace_I_with_C_I_C_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_I_C(fgFLOAT64);
}

////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : test operand 2
 *  @param dattrue
 *  @param vec_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_C_I_C(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Vector *vec_test2,
				     FLGR_Data1D *dattrue, FLGR_Vector *vec_false) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) | (dattrue==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest1, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_C_I_C,datout,dattest1,tst,vec_test2,dattrue,vec_false);


}
////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param dattrue
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_S_I_S(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, char *str_test2,
				     FLGR_Data1D *dattrue, char *str_false) {
  int ret;
  FLGR_Vector *vector_test2;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattrue==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);
  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr1d_replace_I_with_C_I_C(datout,dattest1,test,vector_test2,dattrue,vector_false);

  flgr_vector_destroy(vector_test2);
  flgr_vector_destroy(vector_false);

  return ret;

}


void flgr1d_replace_I_with_C_C_I_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
				       FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgBIT);
}

void flgr1d_replace_I_with_C_C_I_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_C_C_I_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0),
					     datfalse);

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_C_C_I_fast_fgUINT8(datout,
					     dattest1,flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0),
					     datfalse);

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_C_C_I_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0),
					     datfalse);

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_C_C_I_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0),
					     datfalse);

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgUINT8);
  }
#else
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgUINT8);
#endif
}

void flgr1d_replace_I_with_C_C_I_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgUINT16);
}

void flgr1d_replace_I_with_C_C_I_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgUINT32);
}

void flgr1d_replace_I_with_C_C_I_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgINT8);
}

void flgr1d_replace_I_with_C_C_I_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgINT16);
}

void flgr1d_replace_I_with_C_C_I_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgINT32);
}

void flgr1d_replace_I_with_C_C_I_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgFLOAT32);
}

void flgr1d_replace_I_with_C_C_I_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_I(fgFLOAT64);
}


////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : test operand 2
 *  @param vec_true
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_C_C_I(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Vector *vec_test2,
				     FLGR_Vector *vec_true, FLGR_Data1D *datfalse) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr1d_is_data_same_attributes(dattest1, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_C_C_I,datout,dattest1,tst,vec_test2,vec_true,datfalse);


}
////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param str_true
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_S_S_I(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, char *str_test2,
				     char *str_true,FLGR_Data1D *datfalse) {
  int ret;
  FLGR_Vector *vector_test2;
  FLGR_Vector *vector_true;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (datfalse==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);
  vector_true = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }


  ret = flgr1d_replace_I_with_C_C_I(datout,dattest1,test,vector_test2,vector_true,datfalse);

  flgr_vector_destroy(vector_test2);
  flgr_vector_destroy(vector_true);

  return ret;

}




void flgr1d_replace_I_with_C_C_C_fgBIT(FLGR_Data1D *datout,
				       FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
				       FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgBIT);
}

void flgr1d_replace_I_with_C_C_C_fgUINT8(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
#ifdef __SSE2__
  if(datout->spp==1) {
    if(test == FLGR_TEST_EQ) {
      flgr1d_replace_I_EQ_C_C_C_fast_fgUINT8(datout,dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0) ,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0));

    }else if(test == FLGR_TEST_INFEQ) {
      flgr1d_replace_I_LE_C_C_C_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0));

    }else if(test == FLGR_TEST_SUPEQ) {
      flgr1d_replace_I_GE_C_C_C_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else if(test == FLGR_TEST_DIFF) {
      flgr1d_replace_I_NE_C_C_C_fast_fgUINT8(datout,
					     dattest1,
					     flgr_get_array_fgUINT8((fgUINT8*) vec_test2->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_true->array,0),
					     flgr_get_array_fgUINT8((fgUINT8*) vec_false->array,0) );

    }else{
      FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgUINT8);
    }
  }else{
    FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgUINT8);
  }
#else
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgUINT8);
#endif
}

void flgr1d_replace_I_with_C_C_C_fgUINT16(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgUINT16);
}

void flgr1d_replace_I_with_C_C_C_fgUINT32(FLGR_Data1D *datout,
					  FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgUINT32);
}

void flgr1d_replace_I_with_C_C_C_fgINT8(FLGR_Data1D *datout,
					FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgINT8);
}

void flgr1d_replace_I_with_C_C_C_fgINT16(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgINT16);
}

void flgr1d_replace_I_with_C_C_C_fgINT32(FLGR_Data1D *datout,
					 FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgINT32);
}

void flgr1d_replace_I_with_C_C_C_fgFLOAT32(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgFLOAT32);
}

void flgr1d_replace_I_with_C_C_C_fgFLOAT64(FLGR_Data1D *datout,
					   FLGR_Data1D *dattest1, FLGR_Test test, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_1D_I_WITH_C_C_C(fgFLOAT64);
}


////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : test operand 2
 *  @param vec_true
 *  @param vec_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_C_C_C(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, FLGR_Vector *vec_test2,
				     FLGR_Vector *vec_true, FLGR_Vector *vec_false) {

  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr1d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst==FLGR_TEST_UNKNOWN)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr1d_replace_I_with_C_C_C,datout,dattest1,tst,vec_test2,vec_true,vec_false);


}
////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data1D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param str_true
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_replace_I_with_S_S_S(FLGR_Data1D *datout,
				     FLGR_Data1D *dattest1, char *test, char *str_test2,
				     char *str_true, char *str_false) {
  int ret;
  FLGR_Vector *vector_test2;
  FLGR_Vector *vector_true;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);
  vector_true = flgr_vector_create(datout->spp,datout->type);
  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr1d_replace_I_with_C_C_C(datout,dattest1,test,vector_test2,vector_true,vector_false);

  flgr_vector_destroy(vector_test2);
  flgr_vector_destroy(vector_true);
  flgr_vector_destroy(vector_false);

  return ret;

}




//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// 2D REPLACE FUNCTIONS
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_I
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_I_I_I(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  FLGR_Data1D **ptest2 = dattest2->row;					\
  FLGR_Data1D **ptrue = dattrue->row;					\
  FLGR_Data1D **pfalse = datfalse->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_I_I_I_##dtype(*pout,*ptest1,tst,*ptest2,	\
					*ptrue,*pfalse);		\
    pout++;								\
    ptest1++;								\
    ptest2++;								\
    ptrue++;								\
    pfalse++;								\
  }									\
  return

/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_I_C
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_I_I_C(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  FLGR_Data1D **ptest2 = dattest2->row;					\
  FLGR_Data1D **ptrue = dattrue->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_I_I_C_##dtype(*pout,*ptest1,tst,*ptest2,	\
					*ptrue,vec_false);		\
    pout++;								\
    ptest1++;								\
    ptest2++;								\
    ptrue++;								\
  }									\
  return

/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_C_C_I
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_I_C_I(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  FLGR_Data1D **ptest2 = dattest2->row;					\
  FLGR_Data1D **pfalse = datfalse->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_I_C_I_##dtype(*pout,*ptest1,tst,*ptest2,	\
					vec_true,*pfalse);		\
    pout++;								\
    ptest1++;								\
    ptest2++;								\
    pfalse++;								\
  }									\
  return

/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_I_C_C
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_I_C_C(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  FLGR_Data1D **ptest2 = dattest2->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_I_C_C_##dtype(*pout,*ptest1,tst,*ptest2,	\
					vec_true,vec_false);		\
    pout++;								\
    ptest1++;								\
    ptest2++;								\
  }									\
  return

/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_C_I_I
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_C_I_I(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  FLGR_Data1D **ptrue = dattrue->row;					\
  FLGR_Data1D **pfalse = datfalse->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_C_I_I_##dtype(*pout,*ptest1,tst,vec_test2,	\
					*ptrue,*pfalse);		\
    pout++;								\
    ptest1++;								\
    ptrue++;								\
    pfalse++;								\
  }									\
  return

/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_C_I_C
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_C_I_C(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  FLGR_Data1D **ptrue = dattrue->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_C_I_C_##dtype(*pout,*ptest1,tst,vec_test2,	\
					*ptrue,vec_false);		\
    pout++;								\
    ptest1++;								\
    ptrue++;								\
  }									\
  return

/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_C_C_I
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_C_C_I(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  FLGR_Data1D **pfalse = datfalse->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_C_C_I_##dtype(*pout,*ptest1,tst,vec_test2,	\
					vec_true,*pfalse);		\
    pout++;								\
    ptest1++;								\
    pfalse++;								\
  }									\
  return

/////////////////////////////////////////////////////////////////////////
// Macro for different type of flgr2d_replace_I_with_C_C_C
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_REPLACE_2D_C_C_C(dtype)				\
  FLGR_Data1D **pout = datout->row;					\
  FLGR_Data1D **ptest1 = dattest1->row;					\
  int i;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(i=0 ; i<datout->size_y ; i++) {					\
    flgr1d_replace_I_with_C_C_C_##dtype(*pout,*ptest1,tst,vec_test2,	\
					vec_true,vec_false);		\
    pout++;								\
    ptest1++;								\
  }									\
  return





void flgr2d_replace_I_with_I_I_I_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
				       FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgBIT);
}
void flgr2d_replace_I_with_I_I_I_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgUINT8);
}
void flgr2d_replace_I_with_I_I_I_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgUINT16);
}
void flgr2d_replace_I_with_I_I_I_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgUINT32);
}
void flgr2d_replace_I_with_I_I_I_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgINT8);
}
void flgr2d_replace_I_with_I_I_I_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgINT16);
}
void flgr2d_replace_I_with_I_I_I_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgINT32);
}
void flgr2d_replace_I_with_I_I_I_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgFLOAT32);
}
void flgr2d_replace_I_with_I_I_I_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_I_I(fgFLOAT64);
}








void flgr2d_replace_I_with_I_I_C_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
				       FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgBIT);
}
void flgr2d_replace_I_with_I_I_C_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgUINT8);
}
void flgr2d_replace_I_with_I_I_C_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgUINT16);
}
void flgr2d_replace_I_with_I_I_C_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgUINT32);
}
void flgr2d_replace_I_with_I_I_C_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgINT8);
}
void flgr2d_replace_I_with_I_I_C_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgINT16);
}
void flgr2d_replace_I_with_I_I_C_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgINT32);
}
void flgr2d_replace_I_with_I_I_C_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgFLOAT32);
}
void flgr2d_replace_I_with_I_I_C_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_I_C(fgFLOAT64);
}










void flgr2d_replace_I_with_I_C_I_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
				       FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgBIT);
}
void flgr2d_replace_I_with_I_C_I_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgUINT8);
}
void flgr2d_replace_I_with_I_C_I_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgUINT16);
}
void flgr2d_replace_I_with_I_C_I_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgUINT32);
}
void flgr2d_replace_I_with_I_C_I_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgINT8);
}
void flgr2d_replace_I_with_I_C_I_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgINT16);
}
void flgr2d_replace_I_with_I_C_I_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgINT32);
}
void flgr2d_replace_I_with_I_C_I_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgFLOAT32);
}
void flgr2d_replace_I_with_I_C_I_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_I_C_I(fgFLOAT64);
}






void flgr2d_replace_I_with_I_C_C_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
				       FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
}
void flgr2d_replace_I_with_I_C_C_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgUINT8);
}
void flgr2d_replace_I_with_I_C_C_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgUINT16);
}
void flgr2d_replace_I_with_I_C_C_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					  FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgUINT32);
}
void flgr2d_replace_I_with_I_C_C_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgINT8);
}
void flgr2d_replace_I_with_I_C_C_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgINT16);
}
void flgr2d_replace_I_with_I_C_C_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					 FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgINT32);
}
void flgr2d_replace_I_with_I_C_C_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgFLOAT32);
}
void flgr2d_replace_I_with_I_C_C_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Data2D *dattest2,
					   FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_I_C_C(fgFLOAT64);
}





void flgr2d_replace_I_with_C_I_I_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
				       FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgBIT);
}
void flgr2d_replace_I_with_C_I_I_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgUINT8);
}
void flgr2d_replace_I_with_C_I_I_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgUINT16);
}
void flgr2d_replace_I_with_C_I_I_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgUINT32);
}
void flgr2d_replace_I_with_C_I_I_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgINT8);
}
void flgr2d_replace_I_with_C_I_I_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgINT16);
}
void flgr2d_replace_I_with_C_I_I_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgINT32);
}
void flgr2d_replace_I_with_C_I_I_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgFLOAT32);
}
void flgr2d_replace_I_with_C_I_I_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_I_I(fgFLOAT64);
}







void flgr2d_replace_I_with_C_I_C_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
				       FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgBIT);
}
void flgr2d_replace_I_with_C_I_C_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgUINT8);
}
void flgr2d_replace_I_with_C_I_C_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgUINT16);
}
void flgr2d_replace_I_with_C_I_C_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgUINT32);
}
void flgr2d_replace_I_with_C_I_C_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgINT8);
}
void flgr2d_replace_I_with_C_I_C_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgINT16);
}
void flgr2d_replace_I_with_C_I_C_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgINT32);
}
void flgr2d_replace_I_with_C_I_C_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgFLOAT32);
}
void flgr2d_replace_I_with_C_I_C_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_I_C(fgFLOAT64);
}










void flgr2d_replace_I_with_C_C_I_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
				       FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgBIT);
}
void flgr2d_replace_I_with_C_C_I_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgUINT8);
}
void flgr2d_replace_I_with_C_C_I_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgUINT16);
}
void flgr2d_replace_I_with_C_C_I_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgUINT32);
}
void flgr2d_replace_I_with_C_C_I_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgINT8);
}
void flgr2d_replace_I_with_C_C_I_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgINT16);
}
void flgr2d_replace_I_with_C_C_I_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgINT32);
}
void flgr2d_replace_I_with_C_C_I_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgFLOAT32);
}
void flgr2d_replace_I_with_C_C_I_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_MACRO_REPLACE_2D_C_C_I(fgFLOAT64);
}






void flgr2d_replace_I_with_C_C_C_fgBIT(FLGR_Data2D *datout,
				       FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
				       FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgBIT);
}
void flgr2d_replace_I_with_C_C_C_fgUINT8(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgUINT8);
}
void flgr2d_replace_I_with_C_C_C_fgUINT16(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgUINT16);
}
void flgr2d_replace_I_with_C_C_C_fgUINT32(FLGR_Data2D *datout,
					  FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					  FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgUINT32);
}
void flgr2d_replace_I_with_C_C_C_fgINT8(FLGR_Data2D *datout,
					FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgINT8);
}
void flgr2d_replace_I_with_C_C_C_fgINT16(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgINT16);
}
void flgr2d_replace_I_with_C_C_C_fgINT32(FLGR_Data2D *datout,
					 FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					 FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgINT32);
}
void flgr2d_replace_I_with_C_C_C_fgFLOAT32(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true,FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgFLOAT32);
}
void flgr2d_replace_I_with_C_C_C_fgFLOAT64(FLGR_Data2D *datout,
					   FLGR_Data2D *dattest1, FLGR_Test tst, FLGR_Vector *vec_test2,
					   FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_MACRO_REPLACE_2D_C_C_C(fgFLOAT64);
}













////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==dattest2[i][j] )
 *    datout[i][j]=dattrue[i][j];
 *  else
 *    datout[i][j]=datfalse[i][j];
 *  \endcode
 *  @param datout   : image output
 *  @param dattest1  : image test operand 1
 *  @param test    : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2  : image test operand 2
 *  @param dattrue  : image value if true
 *  @param datfalse : image value if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_I_I_I(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Data2D *dattest2,
				     FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (dattrue==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest2, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattrue, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_I_I_I,datout,dattest1,tst,dattest2,dattrue,datfalse);

  return 0;

}





////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==dattest2[i][j] )
 *    datout[i][j]=dattrue[i][j];
 *  else
 *    datout[i][j]=*vfalse;
 *  \endcode
 *  @param datout    : image output
 *  @param dattest1   : image test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2   : image test operand 2
 *  @param dattrue   : image value if true
 *  @param vec_false : constant pointer if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_I_I_C(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Data2D *dattest2,
				     FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (dattrue==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest2, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_I_I_C,datout,dattest1,tst,dattest2,dattrue,vec_false);

}




////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==dattest2[i][j] )
 *    datout[i][j]=*vtrue;
 *  else
 *    datout[i][j]=datfalse[i][j];
 *  \endcode
 *  @param datout    : image output
 *  @param dattest1   : image test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2   : image test operand 2
 *  @param vec_true  : constant pointer if true
 *  @param datfalse  : image value if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_I_C_I(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Data2D *dattest2,
				     FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest2, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }


  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_I_C_I,datout,dattest1,tst,dattest2,vec_true,datfalse);

}




////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==dattest2[i][j] )
 *    datout[i][j]=*vtrue;
 *  else
 *    datout[i][j]=*vfalse;
 *  \endcode
 *  @param datout    : image output
 *  @param dattest1   : image test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2   : image test operand 2
 *  @param vec_true  : constant pointer if true
 *  @param vec_false : constant pointer if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_I_C_C(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Data2D *dattest2,
				     FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest1, dattest2, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_I_C_C,datout,dattest1,tst,dattest2,vec_true,vec_false);

}



////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==*vtest2 )
 *    datout[i][j]=dattrue[i][j];
 *  else
 *    datout[i][j]=datfalse[i][j];
 *  \endcode
 *  @param datout    : image output
 *  @param dattest1   : image test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : constant pointer for test operand 2
 *  @param dattrue   : image value if true
 *  @param datfalse  : image value if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_C_I_I(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Vector *vec_test2,
				     FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattrue==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest1, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(datfalse, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_C_I_I,datout,dattest1,tst,vec_test2,dattrue,datfalse);

}




////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==*vtest2 )
 *    datout[i][j]=dattrue[i][j];
 *  else
 *    datout[i][j]=*vfalse;
 *  \endcode
 *  @param datout    : image output
 *  @param dattest1   : image test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : constant pointer test operand 2
 *  @param dattrue   : image value if true
 *  @param vec_false : constant pointer if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_C_I_C(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Vector *vec_test2,
				     FLGR_Data2D *dattrue, FLGR_Vector *vec_false) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattrue==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest1, dattrue, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_C_I_C,datout,dattest1,tst,vec_test2,dattrue,vec_false);

}





////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==*vtest2 )
 *    datout[i][j]=*vtrue;
 *  else
 *    datout[i][j]=datfalse[i][j];
 *  \endcode
 *  @param datout    : image output
 *  @param dattest1   : image test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : constant pointer for test operand 2
 *  @param vec_true  : constant pointer if true
 *  @param datfalse  : image value if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_C_C_I(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Vector *vec_test2,
				     FLGR_Vector *vec_true, FLGR_Data2D *datfalse) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (datfalse==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;
  if( (ret=flgr2d_is_data_same_attributes(dattest1, datfalse, __FUNCTION__)) != FLGR_RET_OK )
    return ret;

  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_C_C_I,datout,dattest1,tst,vec_test2,vec_true,datfalse);

}




////////////////////////////////////////////////////////////////////////////
/*! compute pixel to pixel replace2d
 *  \code
 *  if( dattest1[i][j]==*vtest2 )
 *    datout[i][j]=dattrue[i][j];
 *  else
 *    datout[i][j]=*vfalse;
 *  \endcode
 *  @param datout    : image output
 *  @param dattest1   : image test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param vec_test2 : constant pointer test operand 2
 *  @param vec_true  : constant pinter value if true
 *  @param vec_false : constant pointer if false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_C_C_C(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char * test, FLGR_Vector *vec_test2,
				     FLGR_Vector *vec_true, FLGR_Vector *vec_false) {
  FLGR_Test tst;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if( (ret=flgr2d_is_data_same_attributes(datout, dattest1, __FUNCTION__)) != FLGR_RET_OK )
    return ret;


  tst=flgr_get_test_value(test);
  if(tst<0)  {
    POST_ERROR("Illegal test %s",test);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_DISPATCH_PROCEDURE(datout->type,flgr2d_replace_I_with_C_C_C,datout,dattest1,tst,vec_test2,vec_true,vec_false);

}









////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data2D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param dattrue
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_I_I_S(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char *test, FLGR_Data2D *dattest2,
				     FLGR_Data2D *dattrue, char *str_false) {
  int ret;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (dattrue==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr2d_replace_I_with_I_I_C(datout,dattest1,test,dattest2,dattrue,vector_false);

  flgr_vector_destroy(vector_false);

  return ret;

}


////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data2D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param str_true
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_I_S_I(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char *test, FLGR_Data2D *dattest2,
				     char *str_true, FLGR_Data2D *datfalse) {
  int ret;
  FLGR_Vector *vector_true;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL) || (datfalse==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_true = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }


  ret = flgr2d_replace_I_with_I_C_I(datout,dattest1,test,dattest2,vector_true,datfalse);

  flgr_vector_destroy(vector_true);

  return ret;

}


////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data2D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param dattest2 : test operand 2
 *  @param str_true
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_I_S_S(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char *test, FLGR_Data2D *dattest2,
				     char *str_true, char *str_false) {
  int ret;
  FLGR_Vector *vector_true;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattest2==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_true = flgr_vector_create(datout->spp,datout->type);
  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr2d_replace_I_with_I_C_C(datout,dattest1,test,dattest2,vector_true,vector_false);

  flgr_vector_destroy(vector_true);
  flgr_vector_destroy(vector_false);

  return ret;

}

////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data2D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=datfalse[i];
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param dattrue
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_S_I_I(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char *test, char *str_test2,
				     FLGR_Data2D *dattrue, FLGR_Data2D *datfalse) {
  int ret;
  FLGR_Vector *vector_test2;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattrue==NULL) || (datfalse==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }


  ret = flgr2d_replace_I_with_C_I_I(datout,dattest1,test,vector_test2,dattrue,datfalse);

  flgr_vector_destroy(vector_test2);

  return ret;

}


////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data2D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param dattrue
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_S_I_S(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char *test, char *str_test2,
				     FLGR_Data2D *dattrue, char *str_false) {
  int ret;
  FLGR_Vector *vector_test2;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (dattrue==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);
  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr2d_replace_I_with_C_I_C(datout,dattest1,test,vector_test2,dattrue,vector_false);

  flgr_vector_destroy(vector_test2);
  flgr_vector_destroy(vector_false);

  return ret;

}

////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data2D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param str_true
 *  @param datfalse
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_S_S_I(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char *test, char *str_test2,
				     char *str_true,FLGR_Data2D *datfalse) {
  int ret;
  FLGR_Vector *vector_test2;
  FLGR_Vector *vector_true;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL) || (datfalse==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);
  vector_true = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }


  ret = flgr2d_replace_I_with_C_C_I(datout,dattest1,test,vector_test2,vector_true,datfalse);

  flgr_vector_destroy(vector_test2);
  flgr_vector_destroy(vector_true);

  return ret;

}




////////////////////////////////////////////////////////////////////////////
/*! compute FLGR_Data2D elements replace
 *  \code
 *  if( dattest1[i]==dattest2[i] )
 *    datout[i]=dattrue[i];
 *  else
 *    datout[i]=vfalse;
 *  \endcode
 *  @param datout
 *  @param dattest1 : test operand 1
 *  @param test     : string for test "<", "<=", "==", ">=", ">", "!="
 *  @param str_test2 : string for vector test operand 2
 *  @param str_true
 *  @param str_false
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_replace_I_with_S_S_S(FLGR_Data2D *datout,
				     FLGR_Data2D *dattest1, char *test, char *str_test2,
				     char *str_true, char *str_false) {
  int ret;
  FLGR_Vector *vector_test2;
  FLGR_Vector *vector_true;
  FLGR_Vector *vector_false;

  FLGR_DECLARE_FUNCTION;

  if((datout==NULL) || (dattest1==NULL))  {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  vector_test2 = flgr_vector_create(datout->spp,datout->type);
  vector_true = flgr_vector_create(datout->spp,datout->type);
  vector_false = flgr_vector_create(datout->spp,datout->type);

  if((ret=flgr_vector_import_string(vector_test2, str_test2))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_test2);
    flgr_vector_destroy(vector_test2);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_true, str_true))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_true);
    flgr_vector_destroy(vector_true);
    return ret;
  }

  if((ret=flgr_vector_import_string(vector_false, str_false))!= FLGR_RET_OK) {
    POST_ERROR("String is not valid ""%s""\n",str_false);
    flgr_vector_destroy(vector_false);
    return ret;
  }


  ret = flgr2d_replace_I_with_C_C_C(datout,dattest1,test,vector_test2,vector_true,vector_false);

  flgr_vector_destroy(vector_test2);
  flgr_vector_destroy(vector_true);
  flgr_vector_destroy(vector_false);

  return ret;

}






//! @}
